package thread;

class MyThread5 extends  Thread {
    @Override
    public void run() {
        //在这个代码中,如果要获取线程的引用,直接使用this即可
//        System.out.println(this.getId() + ", " + this.getName());
        System.out.println(Thread.currentThread().getId()+", "+Thread.currentThread().getName());
    }
}
public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        MyThread5 t1 = new MyThread5();
        MyThread5 t2 = new MyThread5();
        t1.start();
        t2.start();
        Thread.sleep(1000);
        System.out.println(t1.getId() + ", " + t1.getName());
        System.out.println(t2.getId() + ", " + t2.getName());

    }
}
